
$(function(){
	$("#reg").click(function(event){
			
			var username=document.getElementById("username").value;
			var password=document.getElementById("password").value;
			var password1=document.getElementById("password1").value;
			var path = document.getElementById("path");
			
			if(password != password1){
				alert("两次输入的密码不一致");
				return false;
			}
			$.ajax({
	            type : "POST",
	            url : $("#regForm").attr("action"),
	            data : {username:username,password:password} ,
	            dataType : "json"
	        }).done(function(data) {
	        	
	        	if(data.success == "true"){
	        		alert("注册成功!");
	        		document.location.href=path.value+"/login";
				}else{
					alert("用户已存在！");
					username.value="";
					password.value="";
					password1.value="";
					return false;
				}
	        });
		
	});
});